import java.util.Arrays;
import java.util.PriorityQueue;

public class Test {
    // 堆排序
    public static void main(String[] args) {
        TestHeap heap = new TestHeap();
        int[] array = { 22,29,15,42,35,62,34,56,19,31};
        heap.createHeap(array);
        heap.heapSort();
        System.out.println(Arrays.toString(heap.elem));
    }

    // 向下调整建堆
    public static void main2(String[] args) {
        TestHeap heap = new TestHeap();
        int[] array = { 22,29,15,42,35,62,34,56,19,31};
        heap.createHeap(array);
        heap.push(66);
        heap.pollHeap();
        System.out.println(heap.peekHeap());
    }

    // 向上调整建堆
    public static void main1(String[] args) {
        TestHeap heap = new TestHeap();
        int[] array = { 22,29,15,42,35,62,34,56,19,31};
        heap.createHeap2(array);
        heap.push(77);
        heap.pollHeap();
        System.out.println(heap.peekHeap());
    }
}
